<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
<title>优惠活动管理</title>
<link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css" />
<script type="text/javascript" src="/js/jq.js"></script>
<script type="text/javascript" src="/js/global.js"></script>
 <script type="text/javascript" src="/js/bootstrap-switch.min.js"></script>
<script type="text/javascript" src="/bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="/css/bootstrap-switch.min.css" />
<link rel="stylesheet" href="/css/jquery.dataTables.min.css" />
<script type="text/javascript"  src="/js/jquery.dataTables.min.js"></script>
<style>
	.btn-editBaiMingDanItem{
		margin-right:20px;
	}
	.save{
	    padding: 15px;
	    text-align: right;
	    border-top: 1px solid #e5e5e5;
	}
	
	.btn-tijiao {
	    color: #fff;
	    background-color: #449d44;
	    border-color: #398439;
	}
	.btn-tijiao:hover{
		color: #fff;
	    background-color: #449d44;
	    border-color: #398439;
	}
 	.div-c-controlBtns {
		display:flex;
		justify-content:flex-end;
		margin-bottom:16px;
	}
		.modal-dialog {
		max-width: 1000px;
	}
	.div-c-controlBtns button + button {
		margin-left:8px;
	}
	.p-c-flexwrapper {
		display:flex;
		justify-content: center;
		align-items:center;
		margin-right:16px;
		margin-bottom:16px;
	}
	.p-c-flexwrapper > span {
		width:132px;
	}
	.p-c-flexwrapper > .form-control {
		width:150px;
	}
	#addAndEditModal .modal-body {
		display:flex;
		flex-wrap:wrap;
	}
	#addAndEditModal1 .modal-body {
		display:flex;
		flex-wrap:wrap;
	}
	.bootstrap-background {
	    color: #fff;
	    display: inline-block;
	    text-align: center;
	    white-space: nowrap;
	    vertical-align: middle;
	    border: 1px solid transparent;
	    padding: 5px 10px;
	    line-height: 1.5;
	    border-radius: 3px;
	    font-size: 12px;
	    cursor: default;	
	}
	.bootstrap-background.info {
		 background-color: #5bc0de;
   		 border-color: #46b8da;
	}
	.bootstrap-background.success {
		background-color: #5cb85c;
	    border-color: #4cae4c;
	}
	.bootstrap-background.all {
		background-color: rgb(65,139,202);
	    border-color: rgb(65,139,202);
	}	
	.img-c-smallPic {
		max-width:60px;
		max-height:60px;
		cursor: pointer;
	}		
	.pic-noticeText {
		display:none;
		margin: 0 16px;
	}
	.pic-noticeText.active {
		display:block;
	}
	.modal {
		overflow: auto!important;
	}
	#editor {
		width:100%;
	}
	.table>tbody>tr>td {
	vertical-align:middle;	
}
.dataTables_wrapper table td, .dataTables_wrapper table th {
	white-space: nowrap;
}
.dataTables_wrapper, .dataTables_wrapper table {
	overflow-x:auto;
	max-width:100%;
}
.dataTables_wrapper table {
	border-collapse: collapse!important;
}
table.dataTable thead th {
	border-bottom-color: #ddd!important;
}
*{margin: 0;padding: 0;font-size: 16px; }
.hidden-td {
	display:none;
}
.w-e-icon-upload2 {
	font-size:60px!important;
}
.hasmaxwidth-td {
  max-width:100px;
  white-space: nowrap;
  text-overflow:ellipsis;
  overflow: hidden;
  cursor: pointer;
  max-height:50px;
}
.butt-tijiao {
	color: #fff;
    background-color: #5cb85c;
    border-color: #4cae4c;
    display: inline-block;
    padding: 6px 12px;
    margin-bottom: 0;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.42857143;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    
     touch-action: manipulation;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    background-image: none;
    border: 1px solid transparent;
    border-radius: 4px;
}
</style>
		<script type="text/javascript" src="/js/wangEditor.min.js"></script>
</head>
<body>
	<div class="div-c-controlBtns" style="display:flex;justify-content:flex-start;">
		<button class="btn btn-primary" id="button-i-addNewZongDaiLi1">新增</button>
	</div>
	<p style="font-weight:bold;color:red;">建议活动图片尺寸大小：640X220,长期有效的活动请勿随意删除.</p>
<table id="table-i-cunkuanList" class="table table-striped table-bordered table-hover">
		<thead>
			<tr>
				<th style="display:none;"></th>
				<th>活动名称</th>
				<th style="display:none;"></th>
				<th id="zengsong" style="display:none;">赠送金额</th>
				<th style="display:none;">活动内容</th>
				<th>活动图片</th>
				<th >排序</th>
				<th >更改排序号</th>
				<th>状态</th>
				<th>创建人</th>
				<th>创建时间</th>
				<th>操作</th>
				<th>内容</th>
				<th style="display:none;"></th>
				<th style="display:none;"></th>
				<th style="display:none;"></th>
				<th style="display:none;"></th>
			</tr>
		</thead>
		<tbody>
		</tbody>
	</table>		
		<!-- 模态框（Modal） -->
		<div class="modal fade" id="addAndEditModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		    <div class="modal-dialog" style="width:1000px;">
		        <div class="modal-content">
		            <div class="modal-header">
		                <button type="button" class="close guanbi" data-dismiss="modal" aria-hidden="true">×</button>
		            </div>
		            <form  action="/activity/editActivity.do" enctype="multipart/form-data" method="post">
		            <input hidden="hidden"  id="input-i-content" />
			            <div class="modal-body">
			            	<input id="input-i-id" name="id" hidden="hidden" class="input-auto" />
			            	<p class="p-c-flexwrapper"><span>活动名称：</span><input name="name" id="input-i-name" required class="input-auto form-control" /></p>
			            	<p class="p-c-flexwrapper" id="bdyhk"><span>赠送金额：</span><input name="present"  id="input-i-presendMoney" required class="input-auto form-control" /></p>
			            	<p class="p-c-flexwrapper" id="rgjk"><span>人工加款赠送：</span><input name="present2" value="" id="input-i-presendMoneyP" required class="input-auto form-control" /></p>
			            	<p class="p-c-flexwrapper" id="zxcz"><span>在线充值赠送：</span><input name="present1" value="" id="input-i-presendMoneyZ" required class="input-auto form-control" /></p>
			            </div>
			            <input onchange='PreviewImage(this)' name="file" id="input-i-filePic" type="file" style="margin-left:6px;" />
			            <p class="pic-noticeText" style="font-weight:bold;color:red;">注：在修改的情况下，如不选择新的图片，则默认保留原有的图片，如选择新的图片，则会替换原有的图片</p>
			            <img id="img-i-loadPic" src="" style="margin:10px auto; max-width:96%;max-height:500px;display:block;" />
		           		    <div style="display:none;" id="editor">
				    		</div>
		            	<p class="save"><input type="submit" class="btn btn-default btn-tijiao" value="提交"> <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button></p>
		            </form>
		        </div>
		    </div>
		</div>
		<!-- /.modal -->
<div class="modal fade" id="noticeModal" tabindex="-1" role="dialog" aria-labelledby="noticeModal" aria-hidden="true" style="z-index:9999;">
    <div class="modal-dialog class-fake-alert">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="modal-body" >
           
            </div>
            <div class="modal-footer">	      
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>   		
<div class="modal fade" id="tanchuangModal" tabindex="-1" role="dialog" aria-labelledby="tanchuangModal" aria-hidden="true">
    <div class="modal-dialog class-fake-alert" style="width:800px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="modal-body" >
            	<h2 class="tanchuang-edit-title">弹窗1内容编辑</h2>
 				<div id="editor2">
	    		</div>            	
            </div>
            <div class="modal-footer">	   
            	<button type="button" class="btn btn-success btn-saveAlertContent">保存</button>   
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>   	
<!-- 模态框（Modal）删除， -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            </div>
            <div class="modal-body">你确定要删除该活动吗？</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger" id="btn-i-delModalBtn">删除</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
	
	
	
	<!-- 模态框（Modal）新增 -->
	
 	 	<div class="modal fade" id="addAndEditModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		    <div class="modal-dialog" style="width:1000px;">
		      <div class="modal-content">
		            <div class="modal-header">
		                <button type="button" class="close guanbi" data-dismiss="modal" aria-hidden="true">×</button>
		            </div>
		            <form  action="/activity/addActivityInfo.do" enctype="multipart/form-data" method="post">
		         	  <input hidden="hidden"  id="input-i-content" /> 
			            <p style="font-weight:bold;color:red;margin-left: 360px">活动名称不能重名，重名添加无效</p>
			             <div class="modal-body">
			            	<input id="input-i-id" name="id" hidden="hidden" class="input-auto" />
			            	<input id="input-i-type" name="type" hidden="hidden" value='100' class="input-auto" />
			            	<p class="p-c-flexwrapper"><span>活动名称：</span><input name="name"  required class="input-auto form-control" /></p>
			            	<p class="p-c-flexwrapper"  id="input-i-name-jd-zsje-p"><span>赠送金额：</span><input name="present"  value="0.00" id="input-i-name-jd-zsje" required class="input-auto form-control" /></p>
			            	<p class="p-c-flexwrapper" id="input-i-name-jd-rgjk-p" ><span>人工加款赠送：</span><input name="present2" value="0.00"  id="input-i-name-jd-rgjk" required class="input-auto form-control" /></p>
			            	<p class="p-c-flexwrapper" id="input-i-name-jd-zxcz-p"><span>在线充值赠送：</span><input name="present1" value="0.00"  id="input-i-name-jd-zxcz" required class="input-auto form-control" /></p>
			            </div> 
			           <input onchange='PreviewImage1(this)' name="file" id="input-i-filePic1" type="file" style="margin-left:6px;" /> 
			            <p class="pic-noticeText" style="font-weight:bold;color:red;">注：在修改的情况下，如不选择新的图片，则默认保留原有的图片，如选择新的图片，则会替换原有的图片</p>
			            <img id="img-i-loadPic1" src="" style="margin:10px auto; max-width:96%;max-height:500px;display:block;" />
		            	<p class="save"><input type="submit" class="btn btn-default btn-tijiao" value="提交"> <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button></p>
		            </form> 
		            
		        </div> 
		    </div>
		</div> 
		
		<!-- 模态框（Modal） -->
		<div class="modal fade" id="addAndEditModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:30%; margin-left:35%;">
		    <div class="modal-dialog">
		        <div class="modal-content" style="text-align:center;margin:0 auto;">
		            <div class="modal-header">
		                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
		            </div>
		          			<p class="p-c-flexwrapper" style="margin:30px 0;"><span style="min-width:300px;">请选择需要创建的活动类型</span></p>
			            	<p class="p-c-flexwrapper"  id="butt-bangdingyhk"><button class="btn btn-info btn-editBaiMingDanItem btn-sm">绑定银行卡送彩金</button></p>
			            	<p class="p-c-flexwrapper" id="butt-zaixianczhisongcj" ><button class="btn btn-info btn-editBaiMingDanItem btn-sm">在线充值赠送彩金</button></p>
			            	<p class="p-c-flexwrapper" id="butt-chuangjianputonghdong"><button class="btn btn-info btn-editBaiMingDanItem btn-sm">创建普通活动</button></p>
		            <div class="modal-footer">
		                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
		            </div>
		        </div>
		    </div>
		</div>
		<!-- 排序号的模态框（Modal） -->
		<div class="modal fade" id="sortActivemodal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		    <div class="modal-dialog">
		        <div class="modal-content">
		            <div class="modal-header">
		                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
		            </div>
		            <form>
		            <div class="modal-body">
		            	<input id="input-activity-id" hidden="hidden" class="input-auto" /> 
		            	<p class="p-c-flexwrapper"><span style="width:150px;">当前排序号：</span><input id="input-i-sort" required class="input-auto form-control" disabled/></p>
		            	<p class="p-c-flexwrapper"><span style="width:150px;">请输入排序号：</span><input id="input-i-en" required class="input-auto form-control" /></p>
		            	<!-- <p class="p-c-flexwrapper p-special2"><span>返水比率：</span><input id="input-i-fanshuilv" type='text' class="form-control" /></p>
		            	<p class="p-c-flexwrapper p-special1"><span style="width:150px;">反水所需打码量：</span><input id="input-i-damaliang" type='text' class="form-control" /></p> -->
		            </div>
		            </form>
		            <div class="modal-footer">
		                <button type="button" class="btn btn-primary" id="button-i-sortModal">提交</button>
		                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
		            </div>
		            </div>
		            </div>
		            </div>
				
		
	<script type="text/javascript" src="/js/zhengzeTools.js"></script>
	<script>

	initEditor("#editor")
	initEditor("#editor2")
	
	function PreviewImage(imgFile) {
		var pattern = /(\.*.jpg$)|(\.*.png$)|(\.*.jpeg$)|(\.*.gif$)|(\.*.bmp$)|(\.*.JPG$)|(\.*.PNG$)|(\.*.JPEG$)|(\.*.GIF$)|(\.*.BMP$)/;
		if (!pattern.test(imgFile.value)) {
			showNoticeModal("系统仅支持jpg/jpeg/png/gif/bmp格式的照片！");
		} else {
			var path;
			if (document.all)//IE 
			{
				imgFile.select();
				path = document.selection.createRange().text;
				document.getElementById("img-i-loadPic").innerHTML = "";
				document.getElementById("img-i-loadPic").style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='scale',src=\""
						+ path + "\")";//使用滤镜效果 
			} else//FF 
			{
				path = URL.createObjectURL(imgFile.files[0]);
				document.getElementById("img-i-loadPic").src = path
			}
		}
	}	
	
	
	 /* 添加新活动 */
	function PreviewImage1(imgFile) {
		var pattern = /(\.*.jpg$)|(\.*.png$)|(\.*.jpeg$)|(\.*.gif$)|(\.*.bmp$)|(\.*.JPG$)|(\.*.PNG$)|(\.*.JPEG$)|(\.*.GIF$)|(\.*.BMP$)/;
		if (!pattern.test(imgFile.value)) {
			showNoticeModal("系统仅支持jpg/jpeg/png/gif/bmp格式的照片！");
		} else {
			var path;
			if (document.all)//IE 
			{
				imgFile.select();
				path = document.selection.createRange().text;
				document.getElementById("img-i-loadPic1").innerHTML = "";
				document.getElementById("img-i-loadPic1").style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='scale',src=\""
						+ path + "\")";//使用滤镜效果 
			} else//FF 
			{
				path = URL.createObjectURL(imgFile.files[0]);
				document.getElementById("img-i-loadPic1").src = path
			}
		}
	}	
	
	bindDelItemEvent("#table-i-cunkuanList", ".btn-c-delactivity", "/activity/deleteActivity.do")
	function DataTables(){
		$("#table-i-cunkuanList").DataTable({
		      // "bPaginate": true,
		      "bLengthChange": true,      
		      "bSort": false,
		      // "bInfo": true,
		       "destroy":true,
		      "bAutoWidth": false,
//			         "bServerSide":true,
		      'aLengthMenu':[5, 20],
		       "searching": false,
		       "dom": `ftp`,
//			    "searching": true,l
		       "language": {//语言设置  
		            "lengthMenu": "每页显示 _MENU_ 条记录",     
		            "zeroRecords": "抱歉你没有添加过任何活动，添加一个试试吧",     
		            "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",     
		            "info": "没有数据",     
		            "oPaginate": {     
		                "sFirst": "首页",     
		                "sPrevious": "前一页",     
		                "sNext": "后一页",     
		                "sLast": "尾页"    
		          	},
		            "search":"搜索:",
		            "infoFiltered":   "(从  _MAX_ 记录中搜索出结果)",
		            "infoEmpty":      "没有找到匹配的信息",
		         },
		         "drawCallback": function( settings ) {
		        	 $(".input-c-mySwitch").bootstrapSwitch()
		         },
		         "ajax": {
		        	 "type": "POST",
		        	 "url": "allActivity.do",
	 	        	 "dataSrc": function(json) {
		        		 var newJson = json.data
		        		 $("div").data("newData",newJson)
		        		 for (var i = 0; i < newJson.length; i++) {
		         			var item = newJson[i]
		         			var timechuo=new Date(item.created_time);
							var time=timechuo.toLocaleDateString().replace(/\//g, "-") + " " + timechuo.toTimeString().substr(0, 8); 
							item.created_time=time
		         			 var stateValue = ""
		        			 if (item.status == "1") {
		        				 stateValue = "checked"
		        			 } else {
		        				 stateValue = ""
		        			 }
		         			item.typeValue = item.type
	         				item.type = "<span class='bootstrap-background " + item.name + "'>" + item.type  + "</span>"
	         				item.status = "<input class='input-c-mySwitch' data-size='small' type='checkbox' " + stateValue + " data-on-text='启用' data-on-color='success' data-off-color='danger' data-off-text='禁用' />"
		        		 	item.photoPath = "<a href='/d/cp/" + item.photo_path + "' target='_blank'><img src='/d/cp/" + item.photo_path + "' class='img-c-smallPic' /></a>"
		        		 	item.qq = "<span class='bootstrap-background " + item.name + "'>" + item.type  + "</span>"
		        		 }
		        		 return newJson
		        	 }, 
		         },
	 	         "columns": [
							 {"data": "id", "className": "hidden-td id-edit-td"},
		                     {"data": "name", "className": "name-edit-td" },
		                     {"data": "typeValue", "className": "huodongduixiang-edit-td hidden-td"},
		                     {"data": "present", "className": "presendMoney-edit-td hidden-td"},
		                     {"data": "present1", "className": "details-edit-td hasmaxwidth-td hidden-td" },
		                     {"data": "photoPath", "className": "photoPath-edit-td" },
		                     {"data": "sort",},
		                     {"data": null, "defaultContent": "<button class='btn btn-default btn-sort'>点击排序</button> "},
		                     {"data": "status",},
		                     {"data": "created_user", },
		                     {"data": "created_time", "className":"created_time-edit-td"},
		                     {"data": null, "defaultContent": "<button class='btn btn-warning btn-c-editZongDaiLiInfo btn-sm'  data-index1='1'>修改</button><button class='btn btn-danger btn-c-delactivity btn-sm' style='margin-left:16px;'>删除</button>"},
		                     {"data": null, "defaultContent": "<button class='btn btn-info btn-sm' data-index='1'>编辑</button> ", "className": "tanchuang1"},
		                     {"data": "alert1", "className": "hidden-td alertcontent-1"},
		                     {"data": "type", "className": "hidden-td type-edit-td"},
		                 ]
		   		 })	
	}
	   		 
	   		 
		var type_obj = {
				"0": {"classN": "success", "text": "绑定银行卡赠送彩金"},
				"1": {"classN": "info", "text": "充值赠送彩金"},
				"2": {"classN": "all", "text": "所有用户"},
		}
		   		 
		   		 
		   		 
	   		 
	   	//对的 打开模态框
	   	$("#button-i-addNewZongDaiLi1").on("click", function(event) {
			$("#addAndEditModal1").attr("data-type1", "add")
			$("#addAndEditModal1").modal("show")
			$("#addAndEditModal1")[0].style.display="flex" 
		})	
		//打开绑定银行卡点击事件
		$("#butt-bangdingyhk").on("click",function(){
			$("#addAndEditModal1").modal("hide")
			$("#addAndEditModal2").modal("show")
			$("#input-i-name-jd-zsje-p")[0].style.display="flex";
			 $("#input-i-name-jd-rgjk-p")[0].style.display="none";
			$("#input-i-name-jd-zxcz-p")[0].style.display="none"; 
			$("#input-i-type").val("0")
		})
		//打开在线充值送彩金
		$("#butt-zaixianczhisongcj").on("click",function(){
			$("#addAndEditModal1").modal("hide")
			$("#addAndEditModal2").modal("show")
			$("#input-i-name-jd-rgjk-p")[0].style.display="flex";
			$("#input-i-name-jd-zxcz-p")[0].style.display="flex"; 
			 $("#input-i-name-jd-zsje-p")[0].style.display="none"; 
			$("#input-i-type").val("1")
		})
		$("#butt-chuangjianputonghdong").on("click",function(){
			$("#addAndEditModal1").modal("hide")
			$("#addAndEditModal2").modal("show")
			$("#input-i-name-jd-zsje-p")[0].style.display="flex";
			$("#input-i-name-jd-rgjk-p")[0].style.display="none";
			$("#input-i-name-jd-zxcz-p")[0].style.display="none"; 
			$("#input-i-type").val("2")
		})
		 $(".btn-primary").on("click", function(){
			/* $("#rgjk")[0].style.display="none";
			$("#zxcz")[0].style.display="none";
			$("#bdyhk")[0].style.display="none"; */
		})	
		//点击排序
		$("#table-i-cunkuanList").on("click", ".btn-sort", function(event) {
			$("#input-i-sort").val($(this).parent().prev().text()); 
			$("#input-activity-id").val($(this).parent().prev().prev().prev().prev().prev().prev().prev().text())
			$("#sortActivemodal").modal("show")
		})
		
		//更改排序号
		$("#button-i-sortModal").on("click",function(){
			$.ajax({
				type: "POST",
	       	 	url: "/activity/sortActivity.do",
	       	 	data:{
	       	 		"id":$("#input-activity-id").val(),
	       	 		"sort":$("#input-i-en").val(),
	       	 		},
	       	 	success:function(data){
	       	 		$("#sortActivemodal").modal("hide")
	       	 			$("#table-i-cunkuanList").DataTable().ajax.url("/activity/allActivity.do").load();
	       	 			/* window.location.reload() */
	       	 		}
	       	 	
			})
		})
		
		$("#button-i-addNewZongDaiLi").on("click", function(event) {
			$("#addAndEditModal").attr("data-type", "add")
			$("#addAndEditModal").modal("show")
		})	   		 
		bindJinYongQiYongSwitch("#table-i-cunkuanList", "editStatus.do", "status")
		$('#addAndEditModal').on('hidden.bs.modal', function () {
			if ($("#addAndEditModal").attr("data-type") == "edit") {
				$("#addAndEditModal form")[0].reset()
				$(".pic-noticeText").removeClass("active")
				$("#img-i-loadPic").attr("src", "")
			}
		})	
		var $ACTIVITY_TR
		$("#table-i-cunkuanList").on("click", ".btn-c-editZongDaiLiInfo", function(event) {
			$("#addAndEditModal").attr("data-type", "edit")
			var $parentTr = $(event.target).closest("tr")
			 $("#addAndEditModal .input-auto").each(function(index, element) {
				$(element).val($parentTr.find("." + element.id.split("-")[2] + "-edit-td").text()) 
			}) 
			$("#img-i-loadPic").attr("src", $parentTr.find(".img-c-smallPic").attr("src"))
			$(".pic-noticeText").addClass("active")
			$("#addAndEditModal .w-e-text")[0].innerHTML = $parentTr.find(".details-edit-td").html()
			$("#addAndEditModal").attr("data-currentindex1", $(event.currentTarget).attr("data-index1"))
			$ACTIVITY_TR = $(event.currentTarget).closest("tr")
			$("#addAndEditModal .w-e-text").html($ACTIVITY_TR.find(".alertcontent-" + $(event.currentTarget).attr("data-index1")).html())
			var type=$(this).parent().next().next().next().text()
			
			if(type==0 || type==2){
				$("#rgjk")[0].style.display="none";
				$("#zxcz")[0].style.display="none";
				$("#bdyhk")[0].style.display="flex";
			}else if(type==1){
				$("#rgjk")[0].style.display="flex";
				$("#zxcz")[0].style.display="flex";
				$("#bdyhk")[0].style.display="none";
			}
			$("#addAndEditModal").modal("show")
			
			
			
			
			var text = $("#input-i-name").val()
			
			var newData = $("div").data(newData)
			for(var i = 0;i < newData.newData.length;i++){
				 var item = newData.newData[i]
				 if(item.name === text){
					  if(item.present != null){
						$("#input-i-presendMoney").val($(this).parent().parent().find("td:eq(3)").text());
					 }
					 if(item.present1 != null){
						 $("#input-i-presendMoneyZ").val(item.present1)
					 }
					 if(item.present2 != null){
						 $("#input-i-presendMoneyP").val(item.present2)
					 } 
				 }
			}
		})
		
	 	$("#table-i-cunkuanList").on("click", "[data-index]", function(event) {
			$(".tanchuang-edit-title").text("内容编辑")
			$("#tanchuangModal").attr("data-currentindex", $(event.currentTarget).attr("data-index"))
			$ACTIVITY_TR = $(event.currentTarget).closest("tr")
			$("#tanchuangModal .w-e-text").html($ACTIVITY_TR.find(".alertcontent-" + $(event.currentTarget).attr("data-index")).html())
			$("#tanchuangModal").modal("show")
		})		 
		
		$("#table-i-zongdailiList").on("click", ".btn-control-startOrBan", function(event) {
		}) 

		var obj = {
			btnName: "#button-i-submitZongDaiLi",
			divName: "#addAndEditModal",
		}
		
		var ajaxObj = {
			"add": "addActivityInfo.do",	
			"edit": "editActivity.do",
		}
		
		checkFormMethod(obj, function() {
			var type = $("#addAndEditModal").attr("data-type")
 			$("#addAndEditModal form").attr("action", ajaxObj[type])
			$("#addAndEditModal form")[0].submit()
		})		
		$("#addAndEditModal").on("shown.bs.modal", function(e) {
			if ($("#addAndEditModal").attr("data-type") === "add") {
				$("#addAndEditModal .w-e-text").html("")
			}
		})
		$(".btn-saveAlertContent").on("click", function(e) {
			var index = $("#tanchuangModal").attr("data-currentindex")
			var request = {
					url: "/activity/editAlter.do",
					type:"post",
					data:{id: $ACTIVITY_TR.find(".id-edit-td").text(),  comment: "alert" + index,},
					dataType:"json",
					success:function(data){
						if (data.data === 1) {
							showNoticeModal("操作成功！")
							DataTables();
						} else {
							showNoticeModal("网络繁忙")
						}
					},
				}
			request.data["alert" + index] = $("#tanchuangModal").find(".w-e-text").html()
			$.ajax(request);				
		})
		
		$("#button-i-submitZongDaiLi").on("click", function(e) {
			var index = $("#addAndEditModal").attr("data-currentindex1")
			var request = {
					url: "/activity/editAlter.do",
					type:"post",
					data:{
						id: $ACTIVITY_TR.find(".id-edit-td").text(),  
						comment: "alert" + index,
						"present":$("#input-i-presendMoney").val(),
 						"present2":$('#input-i-presendMoneyP').val(),
						"present1":$('#input-i-presendMoneyZ').val()
					},
					dataType:"json",
					success:function(data){
						if (data.data === 1) {
							showNoticeModal("操作成功！")
							setTimeout(function() {
								window.location.reload()
							}, 1000)
						} else {
							showNoticeModal("网络繁忙")
						}
					},
				}
			request.data["alert" + index] = $("#addAndEditModal").find(".w-e-text").html()
			$.ajax(request);				
		})
		DataTables();
	</script>
</body>
</html>